use std::ops::{Add};



include!("data.rs");
include!("request.rs");


pub fn login(username:&str, password:&str) -> String
{
    let mut parameters = Parameters::new();

    parameters.insert_parameter(("type".to_string(),"LOGIN".to_string()));
    parameters.insert_parameter(("username".to_string(),username.to_string()));
    parameters.insert_parameter(("password".to_string(),password.to_string()));

    let url = ROOT_URL.clone().add("/UserServlet");
    let result:Option<reqwest::blocking::Response> = post(url.as_str(), &parameters);
    match result
    {
        Option::Some(response) => response.text().unwrap(),
        Option::None => String::from("error")
    }
}


pub fn register(username:&str, password:&str) -> String
{
    let mut parameters = Parameters::new();

    parameters.insert_parameter(("type".to_string(),"REGISTER".to_string()));
    parameters.insert_parameter(("username".to_string(),username.to_string()));
    parameters.insert_parameter(("password".to_string(),password.to_string()));

    let url = ROOT_URL.clone().add("/UserServlet");
    let result:Option<reqwest::blocking::Response> = post(url.as_str(), &parameters);
    match result
    {
        Option::Some(response) => response.text().unwrap(),
        Option::None => String::from("error")
    }
}



